﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xinkui.WebModel.Cache.View;
using Xinkui.Common;
using System.Threading;
using Xinkui.DataAccess.AutoGenerator;
using Xinkui.Entity.AutoGenerator;

namespace Xinkui.WebModel.Cache {
    public static class CompanyInfoCache {

        public static CompanyInfoView View(int companyId) {
            return CacheProxy.Get<CompanyInfoView>(SystemConst.CacheConst.GetCompanyKey(companyId), () =>
               {
                   return ViewFromDb(companyId);
               });
        }


        public static CompanyInfoView ViewFromDb(int companyId) {

            CompanyInfo_Entity companyEntity = Singleton<CompanyInfoDataAccess>.Instance.CompanyInfo_View(companyId);
            if (companyEntity == null) return null;
            return CompanyInfoView.Convert(companyEntity);
        }

        public static void Remove(int companyId) {
            CacheProxy.Remove(SystemConst.CacheConst.GetCompanyKey(companyId));
        }
    }
}
